package com.yincheng.oes.business.model.export.dto;

import com.yincheng.oes.business.util.ArrayUtil;
import com.yincheng.oes.business.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author: yangsy
 * @Contact: 446948434@qq.com
 * @Date: 2021/8/29 20:01
 * @Version: 1.0
 * @Description:
 */
public class ExportStudentPaperQuestionDTO {

    private static final char NEWLINE_CHAR = '\n';

    /**
     * 答卷id
     */
    private String paperResultId;

    /**
     * 题目序号
     */
    private Integer quesOrder;

    /**
     * 主题干
     */
    private String stem;

    /**
     * 分题干
     */
    private String branch;

    /**
     * 题目选项集合
     */
    private List<String> options;

    /**
     * 题目选项标题集合
     */
    private List<String> optionTitles;

    /**
     * 参考答案
     */
    private String answer;

    /**
     * 我的答案
     */
    private String myAnswer;

    /**
     * 关联知识点集合
     */
    private List<String> contents;

    /**
     * 答案详解
     */
    private String analysis;

    /**
     * 是否正确，0：否，1：是
     */
    private String correctFlag;

    @Override
    public String toString() {
        return "ExportStudentPaperQuestionDTO{" +
                "paperResultId='" + paperResultId + '\'' +
                ", quesOrder=" + quesOrder +
                ", stem='" + stem + '\'' +
                ", branch='" + branch + '\'' +
                ", options=" + options +
                ", optionTitles=" + optionTitles +
                ", answer='" + answer + '\'' +
                ", myAnswer='" + myAnswer + '\'' +
                ", contents=" + contents +
                ", analysis='" + analysis + '\'' +
                ", correctFlag='" + correctFlag + '\'' +
                '}';
    }

    public Integer getQuesOrder() {
        return quesOrder;
    }

    public void setQuesOrder(Integer quesOrder) {
        this.quesOrder = quesOrder;
    }

    public String getPaperResultId() {
        return paperResultId;
    }

    public void setPaperResultId(String paperResultId) {
        this.paperResultId = paperResultId;
    }

    public String getCorrectFlag() {
        return correctFlag;
    }

    public void setCorrectFlag(String correctFlag) {
        this.correctFlag = correctFlag;
    }

    public String getStem() {
        return stem == null ? StringUtils.EMPTY : StringUtil.transform(stem);
    }

    public void setStem(String stem) {
        this.stem = stem;
    }

    public String getBranch() {
        return branch == null ? StringUtils.EMPTY : StringUtil.transform(branch);
    }

    public void setBranch(String branch) {
        this.branch = branch;
    }

    /**
     * 题目信息：题干+分题干拼接，中间换行
     *
     * @return 题目信息
     */
    public String getQuestion() {
        StringBuilder stringBuilder = new StringBuilder();

        if (StringUtils.isNotBlank(stem)) {
            stringBuilder.append(stem);
        }
        if (StringUtils.isNotBlank(stem) && StringUtils.isNotBlank(branch)) {
            stringBuilder.append(NEWLINE_CHAR).append(branch);
        }
        if (StringUtils.isBlank(stem) && StringUtils.isNotBlank(branch)) {
            stringBuilder.append(branch);
        }
        return StringUtil.transform(stringBuilder.toString());
    }

    public List<String> getOptions() {
        return options == null ? new ArrayList<>() : ArrayUtil.transform(options);
    }

    public void setOptions(List<String> options) {
        this.options = options;
    }

    public List<String> getOptionTitles() {
        return optionTitles == null ? new ArrayList<>() : optionTitles;
    }

    public void setOptionTitles(List<String> optionTitles) {
        this.optionTitles = optionTitles;
    }

    public String getAnswer() {
        return answer == null ? StringUtils.EMPTY : StringUtil.transform(answer);
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public String getMyAnswer() {
        return myAnswer == null ? StringUtils.EMPTY : StringUtil.transform(myAnswer);
    }

    public void setMyAnswer(String myAnswer) {
        this.myAnswer = myAnswer;
    }

    public List<String> getContents() {
        return contents == null ? new ArrayList<>() : ArrayUtil.transform(contents);
    }

    public void setContents(List<String> contents) {
        this.contents = contents;
    }

    public String getAnalysis() {
        return analysis == null ? StringUtils.EMPTY : StringUtil.transform(analysis);
    }

    public void setAnalysis(String analysis) {
        this.analysis = analysis;
    }

}
